export function getColorOfWeight(minValue,maxValue,colorStart,colorEnd,value){
    const colorR=((colorEnd.r-colorStart.r)*(value-minValue))/(maxValue-minValue)+colorStart.r;
    const colorG=((colorEnd.g-colorStart.g)*(value-minValue))/(maxValue-minValue)+colorStart.g;
    const colorB=((colorEnd.b-colorStart.b)*(value-minValue))/(maxValue-minValue)+colorStart.b;
    return `rgb(${parseInt(colorR).toString()},${parseInt(colorG).toString()},${parseInt(colorB).toString()}`
}
export function getRandomNum(num,max,min){
    let data=[];
    for(let i=0;i<num;i++){
        data.push(parseInt(Math.random()*(max-min+1)+min,10))
    }
    return data;
}
export function getCurrentTime(fields = 's',time=null) {
    const date = time?new Date(time):new Date();
    let str = '';
    let y = date.getFullYear().toString();
    let m = (date.getMonth() + 1).toString();
    m = m.length == 1 ? '0' + m : m
    let d = date.getDate().toString();
    d = d.length == 1 ? '0' + d : d
    let h = date.getHours().toString();
    h = h.length == 1 ? '0' + h : h
    let i = date.getMinutes().toString();
    i = i.length == 1 ? '0' + i : i
    let s = date.getSeconds().toString();
    s = s.length == 1 ? '0' + s : s
    if (fields == 'y') {
        str = y;
    }
    if (fields == 'm') {
        str = y + '-' + m
    }
    if (fields == 'd') {
        str = y + '-' + m + '-' + d
    }
    if (fields == 'h') {
        str = y + '-' + m + '-' + d + ' ' + h
    }
    if (fields == 'i') {
        str = y + '-' + m + '-' + d + ' ' + h + ':' + i
    }
    if (fields == 's') {
        str = y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s
    }
    return str;
}
